<?php
/**
 * Created by PhpStorm.
 * User: liubo
 * Date: 2018/3/20
 * Time: 17:21
 */
function myUrl($route,$params=[],$order=[],$field=null){

    //只需要在这个方法修改配置
    \think\Config::set('url_common_param',true);
    $params['order_field'] = $field;

    //title asc title desc   site desc  site asc
    $params['order_type'] = (isset($order['order_field']) && isset($order['order_type'])&&$order['order_field']==$field && $order['order_type']=='asc' ) ?'desc':'asc'; //'asc';


    return url($route,$params);
}


function classOrder($order=[],$field=null){

    //代码严谨性验证。用户只传入了title没有传递desc|asc  ''

    if(!isset($order['order_field'])&&!isset($order['order_type'])) return '';

    if($order['order_field']==$field){
        return $order['order_type']=='asc' ?'desc':'asc';
    }
    else{
        return '';
    }



}